#pragma once

#include "Point.h"


namespace uml {

const double Point::x_default_ = 0;
const double Point::y_default_ = 0;
void Point::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    x_ = json.value("x").toDouble(x_default_);
    y_ = json.value("y").toDouble(y_default_);
}

void Point::toJson(QJsonObject& json) {
    if (x_ != x_default_) {
        json.insert("x", x_);
    }
    if (y_ != y_default_) {
        json.insert("y", y_);
    }
}

/// <summary>
/// x getter
/// a real number (<= 0 or >= 0) that represents the x-coordinate of the point.
/// </summary>
double Point::x() const {
    return x_;
}

/// <summary>
/// x setter
/// a real number (<= 0 or >= 0) that represents the x-coordinate of the point.
/// </summary>
void Point::setX(double value) {
    x_ = value;
}

/// <summary>
/// y getter
/// a real number (<= 0 or >= 0)  that represents the y-coordinate of the point.
/// </summary>
double Point::y() const {
    return y_;
}

/// <summary>
/// y setter
/// a real number (<= 0 or >= 0)  that represents the y-coordinate of the point.
/// </summary>
void Point::setY(double value) {
    y_ = value;
}

} // namespace uml
